/********************************************************************************
 * @file   gkt_compiler_default.h
 * @brief  compiler default header file
 * @date   8/Oct/2018
 ********************************************************************************/
 
#ifndef GKT_COMPILER_DEFAULT_H
#define GKT_COMPILER_DEFAULT_H

#ifndef GKT_COMPILER_H
#error "DO NOT INCLUDE THIS FILE DIRECTLY, INCLUDE 'gkt_compiler.h' INSTEAD!"
#endif

#ifndef __ASM
#define __ASM	asm
#endif

#ifndef __INLINE
#define __INLINE	inline
#endif

#ifndef __STATIC_INLINE
#define __STATIC_INLINE	static inline
#endif

#ifndef __NO_RETURN
#define __NO_RETURN
#endif

#ifndef __NAKED
#define __NAKED
#endif

#ifndef __STDCALL
#define __STDCALL	stdcall
#endif

#ifndef __CDCEL
#define __CDCEL	cdcel
#endif

#ifndef __USED
#define __USED
#endif

#ifndef __WEAK
#define __WEAK
#endif

#ifndef __ALIAS
#define __ALIAS(x)
#endif

#ifndef __ALIGNED
#define __ALIGNED(x)
#endif

#ifndef __UNALIGNED_UINT32
#define __UNALIGNED_UINT32(x)
#endif

#ifndef __PACKED
#define __PACKED
#endif

#ifndef __PACKED_STRUCT
#define __PACKED_STRUCT
#endif

/* section */
#ifndef __SECTION
#define __SECTION(name)
#endif


/* struct member offset */
#ifndef __MEMBER_OFFSET
#define __MEMBER_OFFSET(TYPE, MEMB)	((unsigned int)&((TYPE *)0)->MEMB)
#endif

/* retrieve the address of struct variable from a MEMBER addr */
#ifndef __CONTAINER_OF
#define __CONTAINER_OF(PTR, TYPE, MEMB)	\
	((TYPE *)((unsigned int)(PTR) - __MEMBER_OFFSET(TYPE, MEMB)))
#endif

/* branch prediction optimize */
#ifndef __LIKELY
#define __LIKELY(exp)
#endif
#ifndef __UNLIKELY
#define __UNLIKELY(exp)
#endif

#ifndef __RESULT_CHECK
#define __RESULT_CHECK
#endif

#ifndef __FORMAT_CHECK
#define __FORMAT_CHECK(check_type, string_index, first_to_check)
#endif

#ifndef __MAX
#define __MAX(a, b)	((a) > (b) ? (a) : (b))
#endif

#ifndef __MIN
#define __MIN(a, b)	((a) < (b) ? (a) : (b))
#endif

#endif	/* GKT_COMPILER_DEFAULT_H */
